package com.etennis.controller;

import com.etennis.pojos.ResponseResult;
import com.etennis.utils.RandomUtil;
import com.etennis.utils.RedisCache;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.naming.spi.ResolveResult;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/demo")
@Slf4j
@Api(tags = "测试")
public class DemoController {
    @Autowired
    RedisCache redisCache;

    @GetMapping("/test1")
    @ApiOperation("account")
    public ResponseResult<List<String>> test1(){
        List<String> list=new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            String account = RandomUtil.generateAccount();
            list.add(account);
        }
        return ResponseResult.okResult(list);
    }

    @GetMapping("/test2")
    @ApiOperation("redis")
    public ResponseResult<Long> test2(){
        redisCache.setCurSeason(1L);
        Long season = redisCache.getCurSeason();
        //Long season=1L;
        return ResponseResult.okResult(season);
    }

}
